#include "stdafx.h"

Tile::Tile(void)
{
}


String^ Tile::Name::get(void)
{
    return mName;
}


void Tile::Name::set(String^ value)
{
    mName = value;
}


int Tile::Type::get(void)
{
    return mType;
}


void Tile::Type::set(int value)
{
    mType = value;
}


int Tile::Velocity::get(void)
{
    return mVelocity;
}

void Tile::Velocity::set(int value)
{
    mVelocity = value;
}

void Tile::Update(void)
{
    // Update Tile Collision Rectangle
    UpdateCollision();

    // Update Tile Sprite
    {
        mSprite->X = Location.X;
        mSprite->Y = Location.Y;
        mSprite->Width = Size.Width;
        mSprite->Height = Size.Height;
        mSprite->Frame = Type;
    }
}

void Tile::GetSprites(List<Sprite^>^ argSpriteList)
{
    // Add Sprite to Sprite List
    argSpriteList->Add(mSprite);
}

Tile^ Tile::Load(TileDescription^ argDesc, Texture^ argTexture)
{
    if (argDesc == nullptr)
        return nullptr;

    // Create Tile
    Tile^ tile = gcnew Tile();

    // Set Tile Properties
    tile->mName = argDesc->Name;
    tile->mType = argDesc->Type;
    tile->mVelocity = argDesc->Velocity;
    tile->CollisionOffset = argDesc->CollisionOffset;

    // Set Tile Sprite
    tile->mSprite = gcnew Sprite(argTexture);
    tile->mSprite->Frame = argDesc->Type;

    // Return Tile
    return tile;
}